﻿using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 菜单和工具
{
    public partial class Form7 : Form
    {
        CefSettings m_cefSettings = new CefSettings();
        ChromiumWebBrowser m_broser;

        public Form7()
        {
            InitializeComponent();

            Init();
        }
        void Init()
        {
            CefSharp.Cef.Initialize(m_cefSettings);
            m_broser = new
                ChromiumWebBrowser("https://baidu.com");//http://www.sanrenyixing.com
            webBrowser1.Controls.Add(m_broser);

            // treeview
            treeView1.BeginUpdate();
            treeView1.Nodes.Add("Parent");
            treeView1.Nodes[0].Nodes.Add("Child 1");
            treeView1.Nodes[0].Nodes.Add("Chi每个节点的高度ld 2");
            treeView1.Nodes[0].Nodes[1].Nodes.Add("Grandchild");
            treeView1.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("Great Grandchild");

            treeView1.Nodes.Add("baidu.com");
            treeView1.Nodes.Add("www.sanrenyixing.com");
            treeView1.EndUpdate();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            m_broser.Load(textBox1.Text);
        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode tree = e.Node;
            m_broser.Load(tree.Text);
        }
    }
}
